<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改作业详情')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-exerciseitem-edit" th:object="${tbeduExerciseitem}">
            <input name="fId" th:field="*{fId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">用户ID：</label>
                <div class="col-sm-8">
                    <input name="fUserid" th:field="*{fUserid}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">任务ID：</label>
                <div class="col-sm-8">
                    <input name="fTaskid" th:field="*{fTaskid}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">核心任务完成度：</label>
                <div class="col-sm-8">
                    <input name="fCore" th:field="*{fCore}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">拓展任务完成度：</label>
                <div class="col-sm-8">
                    <input name="fExpand" th:field="*{fExpand}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">日志：</label>
                <div class="col-sm-8">
                    <textarea name="fLog" class="form-control" required>[[*{fLog}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">文件路径：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="fFile" th:field="*{fFile}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="fFile" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">拓展：</label>
                <div class="col-sm-8">
                    <input name="fAppendix" th:field="*{fAppendix}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">复习任务完成度：</label>
                <div class="col-sm-8">
                    <input name="fReview" th:field="*{fReview}" class="form-control" type="text" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "manager/exerciseitem";
        $("#form-exerciseitem-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-exerciseitem-edit').serialize());
            }
        }

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>
</body>
</html>